Core, BigQuery: refactor 'client_info' support.#7849
Core, BigQuery: refactor 'client_info' support.#7849tseaver merged 14 commits intogoogleapis:masterfrom tseaver:7825-add-client_info-refactor
Conversation
Deprecate the 'USER_AGENT' and '_EXTRA_HEADERS' class-level attributes.
tswast
left a comment
There was a problem hiding this comment.
LGTM.
We'll need to bump the min version of the dependency on google-cloud-core in google-cloud-bigquery, though, right?
Yes, and for the other manual / JSON clients which will rely on this feature in future PRs. |
| _GRPC_VERSION = None | ||
|
|
||
|
|
||
| class ClientInfo(object): |
There was a problem hiding this comment.
@tswast In order to support the API libraries which do not install grpc, I had to split out a base ClientInfo class which is importable if 'grpc' is absent. The one in google.api_core.gapic_v1.client_info subclasses and adds the to_grpc_metadata method.
|
Let's add |
| _GRPC_VERSION = None | ||
|
|
||
|
|
||
| class ClientInfo(object): |
|
|
||
| try: | ||
| _GRPC_VERSION = pkg_resources.get_distribution("grpcio").version | ||
| except pkg_resources.DistributionNotFound: # pragma: NO COVER |
There was a problem hiding this comment.
Should we add a unit test for this? It'd be good to be doubly sure that it doesn't blow up when _GRPC_VERSION is None.
* Add 'user_agent' and 'extra_headers' properties to 'Connection'. Deprecate the 'USER_AGENT' and '_EXTRA_HEADERS' class-level attributes. * Add 'client_info' parameter to 'Connection' ctor. * Implement 'Connection.user_agent' via its '_client_info'. * Ensure 'X-Goog-API-Client' header is always passed. * Create/use non-GAPIC-specific 'ClientInfo' class FBO HTTP/JSON clients. Derive the existing GAPIC class from it.
* Add 'user_agent' and 'extra_headers' properties to 'Connection'. Deprecate the 'USER_AGENT' and '_EXTRA_HEADERS' class-level attributes. * Add 'client_info' parameter to 'Connection' ctor. * Implement 'Connection.user_agent' via its '_client_info'. * Ensure 'X-Goog-API-Client' header is always passed. * Create/use non-GAPIC-specific 'ClientInfo' class FBO HTTP/JSON clients. Derive the existing GAPIC class from it.
Hoist
client_infosupport fromgoogle.cloud.bigquery._http.Connectioninto core'sgoogle.cloud._http.Connection.Toward #7825.